/**
 * 获取验证码
 * @param {Object} vm
 * @param {Object} params
 */
export function getPhoneCode(vm,params) {
	vm.$u.api.getPhoneCode(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.$refs.uCode.start();
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 修改手机号获取验证码
 * @param {Object} vm
 * @param {Object} params
 */
export function getPhoneCodeNow(vm,params) {
	vm.$u.api.getPhoneCodeNow(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.$refs.uNCode.start();
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 登陆
 * @param {Object} vm
 * @param {Object} params
 */
export function login(vm,params) {
	vm.$u.api.login(params).then(res=>{
		if(res.code==200){
			vm.$u.toast(res.msg);

			let userBaseInfo = {
				spread_code: res.data.spread_code,
				name: res.data.name,
				create_time: res.data.create_time,
				last_time: res.data.last_time
			};
			uni.setStorageSync('userBaseInfo', userBaseInfo);

			uni.setStorageSync('Authori-zation', "Bearer "+res.data.token);
			vm.$u.api.config["Authori-zation"] = uni.getStorageSync('Authori-zation');
			// #ifdef MP-WEIXIN
			uni.getSetting({
				success: function (a) {
					uni.getUserProfile({
						desc:'Wexin',
						success: function (b) {
							 uni.login({
							    success (res1) {
									uni.hideLoading();
							        if (res1.code) {
										wxminiGetOpenid(vm,{code:res1.code})
							        } else {
										vm.$u.toast("授权获取失败");
							        }
							    }
							})
						}
					});
				}
			});
			// #endif
			uni.navigateBack({
				delta:1
			})
			//jumpPage(vm,"switchTab","/pages/tabBar/home",{});
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 注册
 * @param {Object} vm
 * @param {Object} params
 */
export function register(vm,params) {
	vm.$u.api.register(params).then(res=>{
		if(res.code==200){
			vm.$u.toast(res.msg);
			if(params.assist_id == 0){
				uni.setStorageSync('Authori-zation', "Bearer "+res.data.token);
				vm.$u.api.config["Authori-zation"] = uni.getStorageSync('Authori-zation');
				if(params.isBack==1){
					uni.navigateBack({
						delta:1
					})
				}else{
					// #ifndef H5
					jumpPage(vm,"reLaunch","/pages/tabBar/home",{});
					// #endif
					// jumpPage(vm,"switchTab","/pages/tabBar/home",{});
					uni.switchTab({
						url: '/pages/tabBar/home',
						success: function (e) {
							//#ifdef H5
							window.location.reload();
							//#endif
							var page = getCurrentPages().pop();
							if (page == undefined || page == null) return;
							page.onLoad();
						}
					})

				}
			}else{
				vm.modelShow=false
				vm.dataList=[];
				vm.pageStart = 1;
				vm.addistList();
			}

		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 忘记密码
 * @param {Object} vm
 * @param {Object} params
 */
export function forgetPassword(vm,params) {
	vm.$u.api.forgetPassword(params).then(res=>{
		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"redirect","/login/login",{});
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 轮播图
 * @param {Object} vm
 * @param {Object} params
 */
export function bannerList(vm,params) {
	vm.$u.api.bannerList(params).then(res=>{
  		if(res.code==200){
			vm.bgColor = res.data.data[0].bg_color
  			vm.bannerList=res.data.data;
			vm.total = res.data.count
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 个人中心菜单/首页导航
 * @param {Object} vm
 * @param {Object} params
 */
export function getMenu(vm,params) {
	vm.$u.api.getMenu(params).then(res=>{
  		if(res.code==200){
  			vm.gridMenuList=res.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 首页优惠券列表
 * @param {Object} vm
 * @param {Object} params
 */
export function userCoupon(vm,params) {
	vm.$u.api.userCoupon(params).then(res=>{
		if(res.code==200){
			vm.couponList = vm.couponList.concat(res.data.data);
		}else{
			//apiError(vm,res)
		}
	});
}

/**
 * 首页优惠券点击后跳转的列表
 * @param {Object} vm
 * @param {Object} params
 */
export function userListCoupon(vm,params) {
	vm.$u.api.userCoupon(params).then(res=>{
  		if(res.code==200){
			if(res.data.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.data.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.couponList = vm.couponList.concat(res.data.data);
				vm.total=res.data.count;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 个人中心优惠券列表
 * @param {Object} vm
 * @param {Object} params
 */
export function listCoupon(vm,params) {
	vm.$u.api.userCoupon(params).then(res=>{
  		if(res.code==200){
			if(res.data.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.data.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.couponList = vm.couponList.concat(res.data.data);
				vm.total=res.data.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 领取优惠券
 * @param {Object} vm
 * @param {Object} params
 */
export function getCoupon(vm,params) {
	vm.$u.api.getCoupon(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.couponList=[];
			vm.pageStart = 1;
			vm.selectCouponList();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 首页推荐商品列表
 * @param {Object} vm
 * @param {Object} params
 */
export function goodsRecommendList(vm,params) {
	vm.$u.api.goodsRecommendList(params).then(res=>{
  		if(res.code==200){
			if(res.count<=vm.goodsSize){
				vm.goodsStatus = 'nomore';
			}
			vm.hotGoodsList = vm.hotGoodsList.concat(res.data);
			vm.goodsTotal=res.count;
  		}else{
			apiError(vm,res)
		}
	});
}
/**
 * 首页推荐商品列表
 * @param {Object} vm
 * @param {Object} params
 */
export function zhiboRoomList(vm,params) {
	vm.$u.api.zhiboRoomList(params).then(res=>{
  		if(res.code==200){
			if(res.count<=vm.goodsSize){
				vm.goodsStatus = 'nomore';
			}
			vm.spread_code=res.data.spread_code;
			vm.roomList = vm.roomList.concat(res.data.list);
			vm.roomTotal=res.count;
  		}else{
			apiError(vm,res)
		}
	});
}
/**
 * 首页推荐商品列表
 * @param {Object} vm
 * @param {Object} params
 */
export function hdList(vm,params) {
	vm.$u.api.hdList(params).then(res=>{
  		if(res.code==200){
			if(res.count<=vm.goodsSize){
				vm.goodsStatus = 'nomore';
			}
			vm.shtxList = vm.shtxList.concat(res.data.shtx);
			vm.roomList = vm.roomList.concat(res.data.hdcx);
			vm.roomTotal=res.count;
  		}else{
			apiError(vm,res)
		}
	});
}
export function pinList(vm,params) {
	vm.$u.api.pinList(params).then(res=>{
  		if(res.code==200){
			if(res.count<=vm.goodsSize){
				vm.goodsStatus = 'nomore';
			}
			vm.roomList = vm.roomList.concat(res.data);
			vm.roomTotal=res.count;
  		}else{
			apiError(vm,res)
		}
	});
}
export function setPinShare(vm,params) {
	vm.$u.api.setPinShare(params).then(res=>{
		console.log(res)//处理详情
	});
}
export function getPinYen(vm,params) {
	vm.$u.api.getPinYen(params).then(res=>{
  		if(res.code==200){
			vm.reloadInfo(); //处理详情
  		}else{
			apiError(vm,res)
		}
	});
}
export function getPinInfo(vm,params) {
	vm.$u.api.getPinInfo(params).then(res=>{
  		if(res.code==200){
			vm.hdInfo  = res.data.detail;
			vm.extra  = res.data.extra;
			vm.setFrom(res.data.detail.content); //处理详情
  		}else{
			apiError(vm,res)
		}
	});
}
export function getCxInfo(vm,params) {
	vm.$u.api.getCxInfo(params).then(res=>{
  		if(res.code==200){
			vm.hdInfo  = res.data.detail;
			vm.extra  = res.data.extra;
			vm.hdGoods = vm.extra.all_goods;
			vm.hdgoods=res.data.goods_zs;
			vm.setFrom(res.data.detail.content); //处理详情
			vm.hdinfoDeal();
  		}else{
			apiError(vm,res)
		}
	});
}
export function setZsGoods(vm,params) {
	vm.$u.api.setZsGoods(params).then(res=>{
  		if(res.code==200){
			vm.chkDeal(res);
  		}else{
			apiError(vm,res)
		}
	});
}
export function getTxInfo(vm,params) {
	vm.$u.api.getTxInfo(params).then(res=>{
  		if(res.code==200){
			vm.hdInfo  = res.data.detail;
			vm.extra  = res.data.extra;
			vm.hdGoods = vm.extra.all_goods;
			vm.setFrom(res.data.detail.content); //处理详情
  		}else{
			apiError(vm,res)
		}
	});
}
/**
 * 商品详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function goodsDetail(vm,params) {
	vm.$u.api.goodsDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data.detail;
			if(vm.goodsInfo.spec_type == 2){
				vm.skuList = res.data.detail.goods_multi_spec.spec_attr;
			}
			vm.file_url = res.data.detail.image[0].file_url;
			vm.setFrom(res.data.detail.content); //处理商品详情
			if(res.data.detail.is_collection == '0'){
				// vm.footerList[1].icon=getApp().globalData.imageUrl+"favorite.png"
				vm.shareImg=getApp().globalData.imageUrl+"favorite.png"
			}else{
				// vm.footerList[1].icon=getApp().globalData.imageUrl+"favorite_end.png"
				vm.shareImg=getApp().globalData.imageUrl+"favorite_end.png"
			}

			//uni.removeStorageSync("goodsInfo");
			//每次进来后，把数据放在缓存中
			var goodids = []
			var goodList = JSON.parse(uni.getStorageSync("goodsInfo") || "[]");
			for (var i = 0; i < goodList.length; i++) {
			  goodids.push(goodList[i].goods_id)
			}
			if (goodids.indexOf(res.data.detail.goods_id) == -1) {
				goodList.push(res.data.detail);
				uni.setStorageSync("goodsInfo",JSON.stringify(goodList));
			}
			vm.dealGoodsHd(res);
			vm.buymin = res.data.detail.goods_sku.buy_min
			vm.step = res.data.detail.goods_sku.buy_add
			vm.popNumber = res.data.detail.goods_sku.buy_min
  		}else if(res.code==300){
			vm.show = true;
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 商品详情页添加取消收藏
 * @param {Object} vm
 * @param {Object} params
 */
export function collect(vm,params) {
	vm.$u.api.collect(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			if(res.data == '0'){
				// vm.footerList[1].icon=getApp().globalData.imageUrl+"favorite.png"
				vm.shareImg=getApp().globalData.imageUrl+"favorite.png"
			}else{
				// vm.footerList[1].icon=getApp().globalData.imageUrl+"favorite_end.png"
				vm.shareImg=getApp().globalData.imageUrl+"favorite_end.png"
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 收货地址列表
 * @param {Object} vm
 * @param {Object} params
 */
export function addressList(vm,params) {
	vm.$u.api.addressList(params).then(res=>{
  		if(res.code==200){
			if(res.data.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.data.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.siteList = vm.siteList.concat(res.data.data);
				vm.total=res.data.count;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 添加修改收货地址
 * @param {Object} vm
 * @param {Object} params
 */
export function editAddress(vm,params) {
	vm.$u.api.editAddress(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"navigateBack","/user/address",{});
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 删除收货地址
 * @param {Object} vm
 * @param {Object} params
 */
export function delAddress(vm,params) {
	vm.$u.api.delAddress(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.siteList=[];
			vm.pageStart = 1;
			vm.selectAddress();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 银行卡列表
 * @param {Object} vm
 * @param {Object} params
 */
export function bankList(vm,params,callback) {
	vm.$u.api.bankList(params).then(res=>{
  		if(res.code==200){
			if(callback){
				callback(res.data)
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 添加修改银行卡
 * @param {Object} vm
 * @param {Object} params
 */
export function editBank(vm,params) {
	vm.$u.api.editBank(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"navigateBack","/user/bank",{});
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 删除银行
 * @param {Object} vm
 * @param {Object} params
 */
export function delBank(vm,params,callback) {
	vm.$u.api.delBank(params).then(res=>{
  		if(res.code==200){
			if(callback){
				callback(res)
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 商品检索列表
 * @param {Object} vm
 * @param {Object} params
 */
export function goodsList(vm,params) {
	vm.$u.api.goodsList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				console.log(res,'goodslist',params);
				vm.goodsList = vm.goodsList.concat(res.data);
				vm.total=res.count;
				vm.isShow = true;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 商品分类
 * @param {Object} vm
 * @param {Object} params
 */
export function categoryList(vm,params) {
	vm.$u.api.categoryList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty1 = true;
			}else{
				vm.current = 0;
				vm.isEmpty1 = false;
				vm.classifyList = res.data;
				vm.cate_id = res.data[0].id;
				vm.selectGoodsList();
			}
  		}else{
			vm.isEmpty1 = true;
			apiError(vm,res)
		}
	});
}

/**
 * 加入购物车
 * @param {Object} vm
 * @param {Object} params
 */
export function addCart(vm,params) {
	vm.$u.api.addCart(params).then(res=>{
  		if(res.code==200){
			//updateType 为0时页面隐藏修改，为1时跳转到确认订单
			if(res.msg != "" && params.updateType==0){
				vm.$u.toast(res.msg);
			}
			if(params.updateType==1){
				var obj={};
				obj.q_id=vm.sectionCurrent+1;
				obj.cart_ids=vm.removeArr;
				obj.type=1;
				uni.navigateTo({
				  url: '/goods/confrimOrder?param='+JSON.stringify(obj)
				});
			}
			getApp().selectCarNum(vm);
			//type为0时购物车页面  1商品详情页面 2为购物车结算
			if(params.type == 0){
				vm.selectCartLists();
			}
  		}else{
			res.updateType=params.updateType;
			apiError(vm,res)
		}
	});
}
export function addCartAssist(vm,params) {
	vm.$u.api.addCart(params).then(res=>{
  		if(res.code==200){
			var obj={};
			obj.q_id=vm.sectionCurrent+1;
			obj.cart_ids=vm.removeArr;
			obj.type=1;
			uni.navigateTo({
				url: '/goods/confirmAssistOrder?param='+JSON.stringify(obj)
			});
			getApp().selectCarNum(vm);

  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 购物车列表
 * @param {Object} vm
 * @param {Object} params
 */
export function cartLists(vm,params) {
	vm.$u.api.cartLists(params).then(res=>{
  		if(res.code==200){
			if(res.data.length == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				vm.carList = res.data;
				vm.selectCarNum();
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 购物车总条数
 * @param {Object} vm
 * @param {Object} params
 */
export function cartCount(vm,params) {
	vm.$u.api.cartCount(params).then(res=>{
  		if(res.code==200){
			if(res.data.all != 0){
				if(vm.sectionList != undefined){
					 vm.sectionList[0].count = res.data.baodan;
					 vm.sectionList[1].count = res.data.youxuan;
					 vm.sectionList[2].count = res.data.fuli;
					 //超享区
					 //vm.sectionList[3].count = res.data.new;
				}
				uni.setTabBarBadge({
				  index: 2,
				  text: JSON.stringify(res.data.all)
				})
			}else{
				vm.sectionList[0].count = 0;
				vm.sectionList[1].count = 0;
				vm.sectionList[2].count = 0;
				//超享区
				vm.sectionList[3].count = 0;
				uni.hideTabBarRedDot({
				  index: 2
				})
			}
  		}
	});
}

/**
 * 购物车删除
 * @param {Object} vm
 * @param {Object} params
 */
export function delCart(vm,params) {
	vm.$u.api.delCart(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			getApp().selectCarNum(vm);
			vm.selectCartLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 评论列表
 * @param {Object} vm
 * @param {Object} params
 */
export function commentList(vm,params) {
	vm.$u.api.commentList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.isEmpty = false;
				vm.commentList = vm.commentList.concat(res.data);
				vm.total = res.count;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 收藏列表
 * @param {Object} vm
 * @param {Object} params
 */
export function collectList(vm,params) {
	vm.$u.api.collectList(params).then(res=>{
  		if(res.code==200){
			if(res.data.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.data.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.goodsList = vm.goodsList.concat(res.data.data);
				vm.total=res.data.count;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 取消收藏(根据id删除，可以批量删除)
 * @param {Object} vm
 * @param {Object} params
 */
export function cancelCollect(vm,params) {
	vm.$u.api.cancelCollect(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.checkNum = 0;
			vm.goodsList=[];
			vm.pageStart = 1;
			vm.selectcollectList();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 查询会员信息
 * @param {Object} vm
 * @param {Object} params
 */
export function userInfo(vm,params) {
	vm.$u.api.userInfo(params).then(res=>{
		if(res.code==200){
			uni.setStorageSync('userLevel', res.data.level);
			vm.uid = res.data.uid;
			vm.edit_num = res.data.edit_num;
			vm.paper_no = res.data.paper_no;
			vm.avatar = res.data.head_img;
			vm.nickName = res.data.name;
			vm.levelName=res.data.level_name;
			vm.level=res.data.level;
			vm.phone=res.data.phone;
			uni.setStorageSync('userPhone', res.data.phone);
			vm.realName=res.data.real_name;
			vm.spread_code=res.data.spread_code;
			//vm.noticeList=res.data.news;
			vm.invitationCode=res.data.leader_code;
			if(params.type == 1){
				// vm.accountList[0].price="¥"+res.data.total_xiaofei;
				// vm.accountList[4].price="¥"+res.data.total_withdraw;
				// vm.accountList[4].price1="¥"+res.data.now_withdraw;
				// vm.accountList[2].price=res.data.points+"个";
				// // vm.accountList[2].price1=res.data.frozen_points+"个";
				// vm.accountList[3].price=res.data.contribution+"个";
				// vm.accountList[1].price=res.data.star+"个";
				// vm.accountList[5].price=res.data.zhuanru;
				// vm.accountList[5].price1=res.data.zhuanchu;

				vm.accountList[4].price1="¥"+res.data.now_withdraw;
				vm.accountList[2].price=res.data.contribution+"个";
				vm.accountList[1].price=res.data.star+"个";
				vm.accountList[3].price=res.data.exchange_show;
				// vm.accountList[4].price=res.data.zhuanru;
				// vm.accountList[4].price1=res.data.zhuanchu;
			}
			vm.now_money=res.data.now_money;
			vm.now_money_show=res.data.now_money_show;
			vm.team_xf_num=res.data.team_xf_num;
			vm.self_xf_num=res.data.self_xf_num
			vm.sm_team_xf_num=res.data.sm_team_xf_num
			vm.bd_num=res.data.bd_num;
			vm.all_now_money=res.data.all_now_money;
			vm.frozen_now_money=res.data.frozen_now_money;
			vm.frozen_now_money_show=res.data.frozen_now_money_show;
			vm.frozen_now_money_old=res.data.frozen_now_money_old;
			vm.frozen_now_money_old_show=res.data.frozen_now_money_old_show;
			vm.now_money_old=res.data.now_money_old;
			vm.now_money_old_show=res.data.now_money_old_show;
			vm.exchange_show=res.data.exchange_show;
			vm.tx_fee = res.data.tx_fee;
			vm.isLogin = true;
		}else{
			vm.noticeList=["请登录"];
			apiError(vm,res)
		}
	});
}

/**
 * 查询业绩
 * @param {Object} vm
 * @param {Object} params
 */
export function notice(vm,params) {
	vm.$u.api.notice(params).then(res=>{
		if(res.code==200){
			vm.noticeList=res.data;
		}else{
			vm.noticeList=["请登录"];
			apiError(vm,res)
		}
	});
}

/**
 * 修改昵称
 * @param {Object} vm
 * @param {Object} params
 */
export function editUserInfo(vm,params) {
	vm.$u.api.editUserInfo(params).then(res=>{
		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.findUserInfo();
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 修改头像
 * @param {Object} vm
 * @param {Object} params
 */
export function editHeadImg(vm,params) {
	uni.uploadFile({
	  url:vm.$u.api.editHeadImg,     // 后端api接口
	  filePath: params, // uni.chooseImage函数调用后获取的本地文件路劲
	  name:'file',//后端通过'file'获取上传的文件对象
	  header:{"Authori-zation":uni.getStorageSync("Authori-zation")},
	  success:(res) => {
		  var data = JSON.parse(res.data);
		  if(data.code==200){
		  	vm.$u.toast(data.msg);
			vm.avatar = data.data.file_url
		  }else{
		  	apiError(vm,data)
		  }
	  }
	});
}

/**
 * 立即购买
 * @param {Object} vm
 * @param {Object} params
 */
export function buyNow(vm,params) {
	vm.$u.api.buyNow(params).then(res=>{
		if(res.code==200 || res.code == 300){
			vm.order = res.data;
			vm.goodsList = res.data.goods_list;
			vm.hdgoods=res.data.goods_zs;

			vm.money_pay_show = res.data.paystate.money_pay_show
			vm.h5_show_ali = res.data.paystate.h5_show_ali
			vm.h5_show_wx = res.data.paystate.h5_show_wx
			vm.app_show_ali = res.data.paystate.app_show_ali
			vm.app_show_wx = res.data.paystate.app_show_wx
			vm.mini_show_ali = res.data.paystate.mini_show_ali
			vm.mini_show_wx = res.data.paystate.mini_show_wx

			if(res.data.goods_list.length>0){
				vm.q_id = res.data.goods_list[0].q_id;
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
		}else{
			apiError(vm,res)
		}
	});
}

/**
 *  确认订单页面结算验证（从商品详情来）
 * @param {Object} vm
 * @param {Object} params
 */
export function isBuyNow(vm,params) {
	vm.$u.api.buyNow(params).then(res=>{
		if(res.code==200){
			vm.modalShow = true;
		}else{
			vm.modalShow = false;
			apiError(vm,res)
		}
	});
}

/**
 * 是否登录
 * @param {Object} vm
 * @param {Object} params
 */
export function isLogin(vm,params) {
	vm.$u.api.isLogin(params).then(res=>{
		if(res.code==200){
			//参数中的type  0:个人中心页面 1:购物车页面  2:商品详情页面  3商品详情 分享
			if(params.type == 0){
				vm.isLogin = true;
			}else if(params.type == 1){
				vm.selectCartLists();
				vm.selectCarNum();
			}else if(params.type == 2){
				// #ifdef H5
				let ua = window.navigator.userAgent.toLowerCase()
				// if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				// 	if(uni.getStorageSync("openidGzh")!=null && uni.getStorageSync("openidGzh")!=""){
				// 		vm.showPopup=true;
				// 	}
				// }else{
					vm.showPopup=true;
				// }
				// #endif
				// #ifndef H5
				vm.showPopup=true;
				// #endif
			}
			else if(params.type == 3){
				vm.showModel = true;
			}
		}else{
			if(params.type == 0){
				vm.nickName = "";
				vm.avatar = "";
				vm.levelName="";
				vm.spread_code=""
			}else if(params.type == 1){
				vm.carList = [];
				vm.totalPrice = "0.00";
				vm.totalPoint = "0";
				vm.removeArr = "";
				vm.checkNum = 0;
				vm.sectionList[0].count = 0;
				vm.sectionList[1].count = 0;
				vm.sectionList[2].count = 0;
				uni.hideTabBarRedDot({
				  index: 2
				})
			}
			vm.isLogin = false;
			apiError(vm,res)
		}
	});
}

/**
 * 获取openid
 * @param {Object} vm
 * @param {Object} params
 */
export function wxminiGetOpenid(vm,params) {
	vm.$u.api.wxminiGetOpenid(params).then(res=>{
		if(res.code==200){
			uni.setStorageSync('openid', res.data.openid);
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从商品详情购买后的支付
 * @param {Object} vm
 * @param {Object} params
 */
export function pay(vm,params) {
	console.log('pay_params',params);
	vm.$u.api.pay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				 wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				  })
			  }
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从商品详情购买后的支付(APP支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function wxPay(vm,params) {
	vm.$u.api.pay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信、支付宝订单数据
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 从商品详情购买后的支付(支付宝支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function payZfb(vm,params) {
	vm.$u.api.pay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
				// location.href  = res.data.payment
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			// #endif
			// #ifdef APP-PLUS
				if(res.data.is_hui == 1){
					let order_no = res.data.order.order_no
					uni.navigateTo({
						url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
					});
					return;
				}else{
					uni.requestPayment({
						provider: 'alipay',
						orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
						success: function (res) {
							jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
						},
						fail: function (err) {
							console.log('fail:' + JSON.stringify(err));
						}
					});
				}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从商品详情购买后的支付(app汇聚支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function hjVxPay(vm,params) {
	vm.$u.api.pay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信、支付宝订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				jumpPage(vm,"navigateTo","/goods/payResult?type=0&order_id="+res.data.order.order_id,{});
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 从商品详情购买后的支付(H5支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function payH5(vm,params) {
	vm.$u.api.pay(params).then(res=>{
		if(res.code==200){
			//location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://testwap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")

		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车到确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCart(vm,params) {
	vm.$u.api.orderCart(params).then(res=>{
		if(res.code==200 || res.code==300){
			vm.order = res.data;

			vm.h5_show_ali = res.data.paystate.h5_show_ali
			vm.h5_show_wx = res.data.paystate.h5_show_wx
			vm.app_show_ali = res.data.paystate.app_show_ali
			vm.app_show_wx = res.data.paystate.app_show_wx
			vm.mini_show_ali = res.data.paystate.mini_show_ali
			vm.mini_show_wx = res.data.paystate.mini_show_wx

			vm.goodsList = res.data.goods_list;
			vm.hdgoods=res.data.goods_zs;
			if(res.data.goods_list.length>0){
				vm.q_id = res.data.goods_list[0].q_id;
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
		}else{
			apiError(vm,res)
		}
	});
}

/**
 *  确认订单页面结算验证（从购物车来）
 * @param {Object} vm
 * @param {Object} params
 */
export function isOrderCart(vm,params) {
	vm.$u.api.orderCart(params).then(res=>{
		if(res.code==200){
			vm.modalShow = true;
		}else{
			vm.modalShow = false;
			apiError(vm,res)
		}
	});
}

/**
 * 从购物车到确认订单后的支付（微信支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function carPay(vm,params) {
	vm.$u.api.carPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购（微信支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function carPayAssist(vm,params) {
	vm.$u.api.assistPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车到确认订单后的支付（支付宝支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCartZfb(vm,params) {
	vm.$u.api.carPay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				    success: function (res) {
				        jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				    },
				    fail: function (err) {
				        console.log('fail:' + JSON.stringify(err));
				    }
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购（支付宝支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCartZfbAssist(vm,params) {
	vm.$u.api.assistPay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				    success: function (res) {
				        jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				    },
				    fail: function (err) {
				        console.log('fail:' + JSON.stringify(err));
				    }
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车到确认订单后的支付（H5支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCartH5(vm,params) {
	vm.$u.api.carPay(params).then(res=>{
		if(res.code==200){
			//location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://testwap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购（H5支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCartH5Assist(vm,params) {
	vm.$u.api.assistPay(params).then(res=>{
		if(res.code==200){
			//location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://testwap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车到确认订单后的支付（APP支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function wxCarPay(vm,params) {
	console.log('wxCarPay_params',params);
	vm.$u.api.carPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信订单数据
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购（ 余额APP支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function wxCarPayAssist(vm,params) {
	console.log('wxCarPay_params',params);
	vm.$u.api.assistPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信订单数据
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车到确认订单后的支付（汇聚APP支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function hjWxCarPay(vm,params) {
	vm.$u.api.carPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购（汇聚APP支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function hjWxCarPayAssist(vm,params) {
	vm.$u.api.assistPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单列表
 * @param {Object} vm
 * @param {Object} params
 */
export function orderList(vm,params) {
	vm.$u.api.orderList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.orderList = vm.orderList.concat(res.data);
				vm.total=res.count;
				vm.isShow = true;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 订单详情
 * @param {Object} vm
 * @param {Object} params
 */
export function orderDetail(vm,params) {
	vm.$u.api.orderDetail(params).then(res=>{
  		if(res.code==200){
			vm.order_info = res.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 判断是否支付
 * @param {Object} vm
 * @param {Object} params
 */
export function isOrderDetail(vm,params) {
	vm.$u.api.orderDetail(params).then(res=>{
  		if(res.code==200){
			if(res.data.pay_status == 1){
				vm.payResImg=getApp().globalData.imageUrl+"order_pay_fail.gif";
				vm.payResTxt="支付失败"
			}else{
				vm.payResImg=getApp().globalData.imageUrl+"order_pay_success.gif";
				vm.payResTxt="支付成功"
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 取消订单
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCancle(vm,params) {
	vm.$u.api.orderCancle(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 订单列表取消订单   为1订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 订单详情支付
 * @param {Object} vm
 * @param {Object} params
 */
export function orderPay(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为订单列表，1为订单详情
				if(params.type == 0){
					 vm.orderList=[];
					 vm.pageStart = 1;
					 vm.selectOrder();
				}else{
					 vm.selectOrderDetail();
				}
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 vm.$u.toast(res.msg);
						 //类型  0为订单列表，1为订单详情
						 if(params.type == 0){
							 vm.orderList=[];
							 vm.pageStart = 1;
							 vm.selectOrder();
						 }else{
							 vm.selectOrderDetail();
						 }
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单详情支付(APP支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function WxOrderPay(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为订单列表，1为订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信、支付宝订单数据
					success (res) {
						//类型  0为订单列表，1为订单详情
						if(params.type == 0){
							vm.orderList=[];
							vm.pageStart = 1;
							vm.selectOrder();
						}else{
							vm.selectOrderDetail();
						}
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单详情支付(汇聚APP支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function hjWxOrderPay(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					//类型  0为订单列表，1为订单详情
					if(params.type == 0){
						vm.orderList=[];
						vm.pageStart = 1;
						vm.selectOrder();
					}else{
						vm.selectOrderDetail();
					}
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信、支付宝订单数据
						success (res) {
							//类型  0为订单列表，1为订单详情
							if(params.type == 0){
								vm.orderList=[];
								vm.pageStart = 1;
								vm.selectOrder();
							}else{
								vm.selectOrderDetail();
							}
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 确认收货
 * @param {Object} vm
 * @param {Object} params
 */
export function orderReceipt(vm,params) {
	vm.$u.api.orderReceipt(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 订单列表取消订单   为1订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 订单商品评价
 * @param {Object} vm
 * @param {Object} params
 */
export function orderComment(vm,params) {
	vm.$u.api.orderComment(params).then(res=>{
		uni.hideLoading();
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type  0全部订单  1待评论 2订单详情
			if(params.type == '0'){
				jumpPage(vm,"navigateBack","/user/orderlist?swiperCurrent=0",{});
			}else if(params.type == '1'){
				jumpPage(vm,"navigateBack","/user/orderlist?swiperCurrent=4",{});
			}else{
				jumpPage(vm,"navigateBack","/user/order_detail?order_id="+params.order_id,{});
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 售后原因
 * @param {Object} vm
 * @param {Object} params
 */
export function refundInfo(vm,params) {
	vm.$u.api.refundInfo(params).then(res=>{
  		if(res.code==200){
			vm.checkList = res.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 订单售后
 * @param {Object} vm
 * @param {Object} params
 */
export function refundApply(vm,params) {
	vm.$u.api.refundApply(params).then(res=>{
		uni.hideLoading();
  		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"redirect","/user/afterSaleList",{});
  		}else{
			apiError(vm,res)
		}
	});
}
export function hdLists(vm,params) {
	vm.$u.api.hdLists(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.pinList = vm.pinList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}
export function pinLists(vm,params) {
	vm.$u.api.pinLists(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.pinList = vm.pinList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 售后列表
 * @param {Object} vm
 * @param {Object} params
 */
export function refundLists(vm,params) {
	vm.$u.api.refundLists(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.saleList = vm.saleList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 取消售后
 * @param {Object} vm
 * @param {Object} params
 */
export function cancelRefund(vm,params) {
	vm.$u.api.cancelRefund(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 填写订单号
 * @param {Object} vm
 * @param {Object} params
 */
export function refundDelivery(vm,params) {
	vm.$u.api.refundDelivery(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 物流公司列表
 * @param {Object} vm
 * @param {Object} params
 */
export function expressList(vm,params) {
	vm.$u.api.expressList(params).then(res=>{
  		if(res.code==200){
			vm.expressList = res.data;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 修改密码
 * @param {Object} vm
 * @param {Object} params
 */
export function editPassword(vm,params) {
	vm.$u.api.editPassword(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.editPasswordShow=false;
			vm.old_password='';
			vm.password='';
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 修改手机号
 * @param {Object} vm
 * @param {Object} params
 */
export function editPhone(vm,params) {
	vm.$u.api.editPhone(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.editPhoneShow=false;
			vm.nowPhoneNumber = vm.phoneNumber;
			uni.setStorageSync('userPhone',vm.phoneNumber);
			vm.phoneNumber='';
			vm.code = '';
			vm.codeText='';
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 个人中心邀请好友
 * @param {Object} vm
 * @param {Object} params
 */
export function spreadBanner(vm,params) {
	vm.$u.api.spreadBanner(params).then(res=>{
		if(res.code==200){
			console.log(res.data.url+"----"+JSON.stringify(params))
			if(res.data.url=='deny'){
				vm.show = true;
			}else{
				vm.imgUrl = res.data.url;
			}
		}else{
			apiError(vm,res)
		}
	})
}

export function presellList(vm,params) {
	vm.$u.api.presellList(params).then(res=>{
  		if(res.code==200){
			vm.roomList = res.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 预售详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function presellDetail(vm,params) {
	vm.$u.api.presellDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data.goods;
			if(vm.goodsInfo.spec_type == 2){
				vm.skuList = res.data.goods.goods_multi_spec.spec_attr;
			}
			vm.presellInfo = res.data;
			vm.goods_id = vm.presellInfo.goods_id;
			vm.setFrom(res.data.content); //处理商品详情
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 预售订单
 * @param {Object} vm
 * @param {Object} params
 */
export function presellOrderList(vm,params) {
	vm.$u.api.presellOrderList(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 创建预售支付订单
 * @param {Object} vm
 * @param {Object} params
 */
export function presellCreateOrder(vm,params) {
	vm.$u.api.presellCreateOrder(params).then(res=>{
		if(res.code==200){
			vm.modalShow = true;
			vm.order_id = res.data.order_id;
			vm.pay_price = res.data.pay_price;
			//var qid = res.data.q_id - 1;
			//jumpPage(vm,"navigateTo",`/user/orderlist?qid=`+qid,{});
		}else{
			vm.$u.toast(res.msg);
		}
	})
}


/**
 * 预售购买
 * @param {Object} vm
 * @param {Object} params
 */
export function presellBuy(vm,params) {
	vm.$u.api.presellBuy(params).then(res=>{
  		if(res.code==200){
			vm.buy_status = 1;
			vm.code = 200;
			vm.goToOrder()
  		}else{
			vm.code = res.code;
			apiError(vm,res);
		}
	});
}


/**
 * 预售确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function presellOrder(vm,params) {
	vm.$u.api.presellOrder(params).then(res=>{
		if(res.code==200){
			vm.order = res.data;
			if(res.data.fail.code == 0){
				vm.$u.toast(res.data.fail.msg);
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
			uni.setStorageSync('address', "");
		}else{
			apiError(vm,res)
		}
	});
}


/**
 * 预售小程序支付
 * @param {Object} vm
 * @param {Object} params
 */
export function presellPay(vm,params) {
	vm.$u.api.presellPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
			}else{
				 wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				  })
			  }
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 预售公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function presellPayGzh(vm,params) {
	vm.$u.api.presellPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 预售支付宝支付(APP和H5)
 * @param {Object} vm
 * @param {Object} params
 */
export function presellPayZfb(vm,params) {
	vm.$u.api.presellPay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				    success: function (res) {
				        jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
				    },
				    fail: function (err) {
				        console.log('fail:' + JSON.stringify(err));
				    }
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 预售H5支付(H5支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function presellPayH5(vm,params) {
	vm.$u.api.presellPay(params).then(res=>{
		if(res.code==200){
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/presell/presellOrder")
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 预售微信APP支付(汇聚支付和官方支付)
 * 借助另一个微信小程序实现
 * @param {Object} vm
 * @param {Object} params
 */
export function presellHjVxPay(vm,params) {
	vm.$u.api.presellPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信、支付宝订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/goods/payResult?type=10",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				jumpPage(vm,"navigateTo","/goods/payResult?type=10&order_id="+res.data.order.order_id,{});
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 创建采购订单
 * @param {Object} vm
 * @param {Object} params
 */
export function stockCreateOrder(vm,params,callback) {
	vm.$u.api.stockCreateOrder(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
			//vm.modalShow = true;
			//vm.order_id = res.data.order_id;
			//vm.pay_price = res.data.pay_price;
		}else{
			vm.num = ''
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 库存划拨
 * @param {Object} vm
 * @param {Object} params
 */
export function stockTransfer(vm,params,callback) {
	vm.$u.api.stockTransfer(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 采购单列表
 * @param {Object} vm
 * @param {Object} params
 */
export function stockOrderList(vm,params,callback) {
	vm.$u.api.stockOrderList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 下级划拨人列表
 *
 * @param {Object} vm
 * @param {Object} params
 */
export function stockTeamList(vm,params,callback) {
	vm.$u.api.stockTeamList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 库存变动明细
 * @param {Object} vm
 * @param {Object} params
 */
export function stockRecordList(vm,params,callback) {
	vm.$u.api.stockRecordList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 下级退货记录
 * @param {Object} vm
 * @param {Object} params
 */
export function stockAuditList(vm,params,callback) {
	vm.$u.api.stockAuditList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 我的退货记录
 * @param {Object} vm
 * @param {Object} params
 */
export function stockRefundList(vm,params,callback) {
	vm.$u.api.stockRefundList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 划拨记录
 * @param {Object} vm
 * @param {Object} params
 */
export function stockTransferList(vm,params,callback) {
	vm.$u.api.stockTransferList(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 库存信息
 * @param {Object} vm
 * @param {Object} params
 */
export function stockInfo(vm,params,callback) {
	vm.$u.api.stockInfo(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 库存信息
 * @param {Object} vm
 * @param {Object} params
 */
export function getOrderPayResult(vm,params,callback) {
	vm.$u.api.getOrderPayResult(params).then(res=>{
		if(callback){
			callback(res)
		}
	})
}

/**
 * 库存信息
 * @param {Object} vm
 * @param {Object} params
 */
export function stockCheckPrice(vm,params,callback) {
	vm.$u.api.stockCheckPrice(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback(res.data)
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}


/**
 * 订单详情支付
 * @param {Object} vm
 * @param {Object} params
 */
export function stockPurchasePay(vm,params) {
	vm.$u.api.stockPurchasePay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				vm.reloadOrder();
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 vm.$u.toast(res.msg);
						 vm.reloadOrder();
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			vm.num = ''
			apiError(vm,res)
		}
	})
}

/**
 * 采购库存微信APP支付(汇聚支付和官方支付)
 * 借助另一个微信小程序实现
 * @param {Object} vm
 * @param {Object} params
 */
export function stockPurchaseHjVxPay(vm,params) {
	vm.$u.api.stockPurchasePay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/stock/orderList",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信、支付宝订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/stock/orderList",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					})
				}
			}else{
				jumpPage(vm,"navigateTo","/stock/orderList",{});
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 预售支付宝支付(APP和H5)
 * @param {Object} vm
 * @param {Object} params
 */
export function stockPurchasePayZfb(vm,params) {
	vm.$u.api.stockPurchasePay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?frombiz=purchase&order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?frombiz=purchase&order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
					provider: 'alipay',
					orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
					success: function (res) {
						jumpPage(vm,"navigateTo","/stock/orderList",{});
					},
					fail: function (err) {
						console.log('fail:' + JSON.stringify(err));
					}
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

export function stockPurchasePayGzh(vm,params) {
	vm.$u.api.stockPurchasePay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/stock/orderList",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/stock/orderList",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 采购库存H5支付(H5支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function stockPurchasePayH5(vm,params) {
	vm.$u.api.stockPurchasePay(params).then(res=>{
		if(res.code==200){
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/stock/orderList")
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 审核通过
 * @param {Object} vm
 * @param {Object} params
 */
export function stockAudit(vm,params) {
	vm.$u.api.stockAudit(params).then(res=>{
		if(res.code==200){
			vm.reloadOrder();
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 发送通知
 * @param {Object} vm
 * @param {Object} params
 */
export function stockNoticeCreate(vm,params) {
	vm.$u.api.stockNoticeCreate(params).then(res=>{
		if(res.code==200){
		}else{
			vm.$u.toast(res.msg);
		}
	})
}


/**
 * 拒绝
 * @param {Object} vm
 * @param {Object} params
 */
export function stockReject(vm,params) {
	vm.$u.api.stockReject(params).then(res=>{
		if(res.code==200){
			vm.reloadOrder();
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 退货
 * @param {Object} vm
 * @param {Object} params
 */
export function stockRefund(vm,params,callback) {
	vm.$u.api.stockRefund(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback()
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 取消订单
 * @param {Object} vm
 * @param {Object} params
 */
export function stockCancelOrder(vm,params,callback) {
	vm.$u.api.stockCancelOrder(params).then(res=>{
		if(res.code==200){
			if(callback){
				callback();
			}
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 秒杀详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillDetail(vm,params) {
	vm.$u.api.seckillDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data.goods;
			if(vm.goodsInfo.spec_type == 2){
				vm.skuList = res.data.goods.goods_multi_spec.spec_attr;
			}
			vm.seckillInfo = res.data;
			vm.down_status = res.data.down_status;
			vm.having_time = res.data.having_time;
			vm.setFrom(res.data.content); //处理商品详情
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀抢购
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillBuy(vm,params) {
	vm.$u.api.seckillBuy(params).then(res=>{
  		if(res.code==200){
			vm.buy_status = 1;
			vm.code = 200;
			vm.goToOrder()
  		}else{
			vm.code = res.code;
			apiError(vm,res);
		}
	});
}

/**
 * 秒杀确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillOrder(vm,params) {
	vm.$u.api.seckillOrder(params).then(res=>{
		if(res.code==200){
			vm.order = res.data;
			vm.h5_show_ali = res.data.paystate.h5_show_ali;
			vm.h5_show_wx = res.data.paystate.h5_show_wx;
			vm.app_show_ali = res.data.paystate.app_show_ali;
			vm.app_show_wx = res.data.paystate.app_show_wx;
			vm.mini_show_ali = res.data.paystate.mini_show_ali;
			vm.mini_show_wx = res.data.paystate.mini_show_wx;
			if(res.data.fail.code == 0){
				vm.$u.toast(res.data.fail.msg);
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
			uni.setStorageSync('address', "");
		}else{
			apiError(vm,res)
		}
	});
}


/**
 * 秒杀小程序支付
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillPay(vm,params) {
	console.log('pay_params',params);
	vm.$u.api.seckillPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				 wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				  })
			  }
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillPayGzh(vm,params) {
	vm.$u.api.seckillPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀H5支付(H5支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillPayH5(vm,params) {
	vm.$u.api.seckillPay(params).then(res=>{
		if(res.code==200){
			//location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://testwap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")

		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀微信APP支付(汇聚支付和官方支付)
 * 借助另一个微信小程序实现
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillHjVxPay(vm,params) {
	vm.$u.api.seckillPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.payment.huiju == 0){
				if(res.data.type == 'balance'){
					jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				}else{
					var orderInfo = {
						"appid": res.data.payment.appid,
						"noncestr": res.data.payment.noncestr,
						"package": res.data.payment.package,
						"partnerid": res.data.payment.partnerid,
						"prepayid": res.data.payment.prepayid,
						"timestamp": res.data.payment.timestamp,
						"sign": res.data.payment.sign
					}
					uni.requestPayment({
						provider: 'wxpay',
						orderInfo: orderInfo, //微信、支付宝订单数据
						success (res) {
							 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
						},
						fail (res) {
						  vm.$u.toast(res.errMsg);
						}
					  })
				}
			}else{
				jumpPage(vm,"navigateTo","/goods/payResult?type=0&order_id="+res.data.order.order_id,{});
				var path = "pages/payIndex/payIndex?rc_result="+ JSON.stringify(res.data.payment);
				vm.sweixin?vm.sweixin.launchMiniProgram({
					id:res.data.payment.original_id,
					path:path
				}):plus.nativeUI.alert('当前环境不支持微信操作!');
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀支付宝支付(APP和H5)
 * @param {Object} vm
 * @param {Object} params
 */
export function seckillPayZfb(vm,params) {
	vm.$u.api.seckillPay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				    success: function (res) {
				        jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				    },
				    fail: function (err) {
				        console.log('fail:' + JSON.stringify(err));
				    }
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀列表
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedList(vm,params) {
	vm.$u.api.timeLimitedList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.seckillList = vm.seckillList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isShow = true;
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 首页秒杀列表
 * @param {Object} vm
 * @param {Object} params
 */
export function indexTimeLimitedList(vm,params) {
	vm.$u.api.timeLimitedList(params).then(res=>{
  		if(res.code==200){
			vm.seckillList = res.data
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀商品详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedDetail(vm,params) {
	vm.$u.api.timeLimitedDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data;
			vm.setFrom(res.data.content); //处理商品详情
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedOrder(vm,params) {
	vm.$u.api.timeLimitedOrder(params).then(res=>{
		if(res.code==200){
			vm.order = res.data;
			if(res.data.fail.code == 0){
				vm.$u.toast(res.data.fail.msg);
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
			uni.setStorageSync('address', "");
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀支付
 * @param {Object} vm
 * @param {Object} params
 */
export function payTimeLimitedOrder(vm,params) {
	vm.$u.api.payTimeLimitedOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀结算验证
 * @param {Object} vm
 * @param {Object} params
 */
export function isTimeLimitedOrder(vm,params) {
	vm.$u.api.timeLimitedOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.fail.code == 0){
				vm.modalShow = false;
				vm.$u.toast(res.data.fail.msg);
			}else{
				vm.modalShow = true;
			}
		}else{
			vm.modalShow = false;
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀订单列表
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedOrderList(vm,params) {
	vm.$u.api.timeLimitedOrderList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.orderList = vm.orderList.concat(res.data);
				vm.total=res.count;
				vm.isShow = true;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀取消订单
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedCancel(vm,params) {
	vm.$u.api.timeLimitedCancel(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 秒杀订单列表取消订单   为1秒杀订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀订单详情支付
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedGoPay(vm,params) {
	vm.$u.api.timeLimitedGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为秒杀订单列表，1为秒杀订单详情
				if(params.type == 0){
					 vm.orderList=[];
					 vm.pageStart = 1;
					 vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 vm.$u.toast(res.msg);
						 //类型  0为秒杀订单列表，1为秒杀订单详情
						 if(params.type == 0){
							 vm.orderList=[];
							 vm.pageStart = 1;
							 vm.selectOrder();
						 }else{
							vm.selectOrderDetail();
						 }
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀订单详情支付(APP支付)
 * @param {Object} vm
 * @param {Object} params
 */
export function WxTimeLimitedGoPay(vm,params) {
	vm.$u.api.timeLimitedGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为秒杀订单列表，1为秒杀订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信、支付宝订单数据
					success (res) {
						//类型  0为秒杀订单列表，1为秒杀订单详情
						if(params.type == 0){
							vm.orderList=[];
							vm.pageStart = 1;
							vm.selectOrder();
						}else{
							vm.selectOrderDetail();
						}
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀订单确认收货
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedReceipt(vm,params) {
	vm.$u.api.timeLimitedReceipt(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 订单列表取消订单   为1订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀订单售后
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedRefundApply(vm,params) {
	vm.$u.api.timeLimitedRefundApply(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"redirect","/seckill/afterSaleList",{});
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀订单详情
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedOrderDetail(vm,params) {
	vm.$u.api.timeLimitedOrderDetail(params).then(res=>{
  		if(res.code==200){
			vm.order_info = res.data;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀售后列表
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedRefundLists(vm,params) {
	vm.$u.api.timeLimitedRefundLists(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.saleList = vm.saleList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀取消售后
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedRefundCancel(vm,params) {
	vm.$u.api.timeLimitedRefundCancel(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 秒杀售后填写订单号
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedRefundDelivery(vm,params) {
	vm.$u.api.timeLimitedRefundDelivery(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 首页拼团列表
 * @param {Object} vm
 * @param {Object} params
 */
export function indexSharingList(vm,params) {
	vm.$u.api.sharingList(params).then(res=>{
  		if(res.code==200){
			vm.grouponList = res.data
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团列表
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingList(vm,params) {
	vm.$u.api.sharingList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.grouponList = vm.grouponList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 拼团商品详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingDetail(vm,params) {
	vm.$u.api.sharingDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data;
			vm.setFrom(res.data.content); //处理商品详情
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团成团记录
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingGroupList(vm,params) {
	vm.$u.api.sharingGroupList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				vm.groupList = res.data;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 拼团确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingOrder(vm,params) {
	vm.$u.api.sharingOrder(params).then(res=>{
		if(res.code==200){
			vm.order = res.data;
			if(res.data.fail.code == 0){
				vm.$u.toast(res.data.fail.msg);
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
			uni.setStorageSync('address', "");
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团支付
 * @param {Object} vm
 * @param {Object} params
 */
export function paySharingOrder(vm,params) {
	vm.$u.api.paySharingOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=2",{});
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=2",{});
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 拼团结算验证
 * @param {Object} vm
 * @param {Object} params
 */
export function isSharingOrder(vm,params) {
	vm.$u.api.sharingOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.fail.code == 0){
				vm.modalShow = false;
				vm.$u.toast(res.data.fail.msg);
			}else{
				vm.modalShow = true;
			}
		}else{
			vm.modalShow = false;
			apiError(vm,res)
		}
	});
}

/**
 * 团购订单列表
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingOrderList(vm,params) {
	vm.$u.api.sharingOrderList(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.orderList = vm.orderList.concat(res.data);
				vm.total=res.count;
				vm.isShow = true;
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 团购订单详情
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingOrderDetail(vm,params) {
	vm.$u.api.sharingOrderDetail(params).then(res=>{
  		if(res.code==200){
			vm.order_info = res.data;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 拼团取消订单
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingCancel(vm,params) {
	vm.$u.api.sharingCancel(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 秒杀订单列表取消订单   为1秒杀订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 拼团订单详情支付
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingGoPay(vm,params) {
	vm.$u.api.sharingGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为拼团订单列表，1为拼团订单详情
				if(params.type == 0){
					 vm.orderList=[];
					 vm.pageStart = 1;
					 vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				wx.requestPayment({
					timeStamp: res.data.payment.timeStamp,
					nonceStr: res.data.payment.nonceStr,
					package: res.data.payment.package,
					signType: res.data.payment.signType,
					paySign: res.data.payment.paySign,
					success (res) {
						 vm.$u.toast(res.msg);
						 //类型  0为拼团订单列表，1为拼团订单详情
						 if(params.type == 0){
							 vm.orderList=[];
							 vm.pageStart = 1;
							 vm.selectOrder();
						 }else{
							vm.selectOrderDetail();
						 }
					},
					fail (res) {
					  console.log("支付失败")
					}
				 })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 拼团订单详情支付（APP支付）
 * @param {Object} vm
 * @param {Object} params
 */
export function WxSharingGoPay(vm,params) {
	vm.$u.api.sharingGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为拼团订单列表，1为拼团订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				var orderInfo = {
					"appid": res.data.payment.appid,
					"noncestr": res.data.payment.noncestr,
					"package": res.data.payment.package,
					"partnerid": res.data.payment.partnerid,
					"prepayid": res.data.payment.prepayid,
					"timestamp": res.data.payment.timestamp,
					"sign": res.data.payment.sign
				}
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: orderInfo, //微信、支付宝订单数据
					success (res) {
						//类型  0为拼团订单列表，1为拼团订单详情
						if(params.type == 0){
							vm.orderList=[];
							vm.pageStart = 1;
							vm.selectOrder();
						}else{
							vm.selectOrderDetail();
						}
					},
					fail (res) {
					  vm.$u.toast(res.errMsg);
					}
				  })
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 拼团订单确认收货
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingReceipt(vm,params) {
	vm.$u.api.sharingReceipt(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			//type为0 订单列表取消订单   为1订单详情取消订单
			if(params.type == 0){
				vm.isShow = false;
				vm.orderList=[];
				vm.pageStart = 1;
				vm.selectOrder();
			}else{
				vm.selectOrderDetail();
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团订单售后
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingRefundApply(vm,params) {
	vm.$u.api.sharingRefundApply(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			jumpPage(vm,"redirect","sharing/afterSaleList",{});
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团售后列表
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingRefundLists(vm,params) {
	vm.$u.api.sharingRefundLists(params).then(res=>{
  		if(res.code==200){
			if(res.count == 0){
				vm.isEmpty = true;
			}else{
				vm.isEmpty = false;
				if(res.count<=vm.pageSize){
					vm.status = 'nomore';
				}
				vm.saleList = vm.saleList.concat(res.data);
				vm.total=res.count;
			}
			vm.isShow = true;
  		}else{
			vm.isEmpty = true;
			apiError(vm,res)
		}
	});
}

/**
 * 拼团取消售后
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingRefundCancel(vm,params) {
	vm.$u.api.sharingRefundCancel(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 拼团售后填写订单号
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingRefundDelivery(vm,params) {
	vm.$u.api.sharingRefundDelivery(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.saleList=[];
			vm.pageStart = 1;
			vm.selectRefundLists();
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 商品详情分享
 * @param {Object} vm
 * @param {Object} params
 */
export function goodsBanner(vm,params) {
	vm.$u.api.goodsBanner(params).then(res=>{
		if(res.code==200){
			vm.imgUrl = res.data.url;
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 活动详情分享
 * @param {Object} vm
 * @param {Object} params
 */
export function cuxiaoBanner(vm,params) {
	vm.$u.api.cuxiaoBanner(params).then(res=>{
		if(res.code==200){
			vm.imgUrl = res.data.url;
		}else{
			apiError(vm,res)
		}
	})
}
export function shtxBanner(vm,params) {
	vm.$u.api.shtxBanner(params).then(res=>{
		if(res.code==200){
			vm.imgUrl = res.data.url;
		}else{
			apiError(vm,res)
		}
	})
}
export function pinBanner(vm,params) {
	vm.$u.api.pinBanner(params).then(res=>{
		if(res.code==200){
			vm.imgUrl = res.data.url;
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 清除token
 * @param {Object} vm
 * @param {Object} params
 */
export function clearToken(vm,params) {
	uni.hideTabBarRedDot({
	  index: 2
	})
	vm.$u.api.config["Authori-zation"] = "";
	vm.$u.api.loginOut(params);
}

/**
 * 我的团队
 * @param {Object} vm
 * @param {Object} params
 */
export function myTeam(vm,params) {
	vm.$u.api.myTeam(params).then(res=>{
		if(res.code==200){

			vm.total=res.count;
			vm.myTeamList = vm.myTeamList.concat(res.data);

			if(res.data.length<10){
				vm.status="nomore"
			}else{
				vm.status="loadmore"
			}

		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 分销记录
 * @param {Object} vm
 * @param {Object} params
 */
export function distributeLog(vm,params) {
	vm.$u.api.distributeLog(params).then(res=>{
		if(res.code==200){
			vm.logList = vm.logList.concat(res.data);
			if(params.type==1){
				for(var i=0;i<vm.logList.length;i++){
					vm.logList[i].describe=vm.logList[i].describe.replace('余额','积分').replace('元','').replace('管理员修改','充值');
					if(vm.logList[i].describe.indexOf("直推")>-1
						||vm.logList[i].describe.indexOf("极差")>-1)
						vm.logList[i].describe="代理差价"
				}
			}
			if(res.data.length<10){
				vm.status="nomore"
			}else{
				vm.status="loadmore"
			}

		}else{
			apiError(vm,res)
		}
	})
}
/**
 *  提现申请
 * @param {Object} vm
 * @param {Object} params
 */
export function withdraw(vm,params) {
	vm.$u.api.withdraw(params).then(res=>{
		if(res.code==200){
			vm.$u.toast("提现申请已提交");
			vm.withdrawPrice=""
			vm.selectDistributeLog();
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 等级变动
 * @param {Object} vm
 * @param {Object} params
 */
export function levelLog(vm,params) {
	vm.$u.api.levelLog(params).then(res=>{
		if(res.code==200){
			vm.logList = res.data;
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从商品详情购买后的公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function payGzh(vm,params) {
	vm.$u.api.pay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 从购物车购买后的公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function orderCartGzh(vm,params) {
	vm.$u.api.carPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 常见问题
 * @param {Object} vm
 * @param {Object} params
 */
export function userProblem(vm,params) {
	vm.$u.api.userProblem(params).then(res=>{
  		if(res.code==200){
  			vm.itemList=res.data.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 个人中心消息列表
 * @param {Object} vm
 * @param {Object} params
 */
export function userMessage(vm,params) {
	vm.$u.api.userMessage(params).then(res=>{
  		if(res.code==200){
  			if(res.data.count == 0){
  				vm.isEmpty = true;
  			}else{
  				vm.isEmpty = false;
  				if(res.data.count<=vm.pageSize){
  					vm.status = 'nomore';
  				}
  				vm.dataList = vm.dataList.concat(res.data.data);
  				vm.total=res.data.count;
  			}
  		}else{
  			vm.isEmpty = true;
  			apiError(vm,res)
  		}
	});
}

/**
 * 关于我们
 * @param {Object} vm
 * @param {Object} params
 */
export function getAboutUs(vm,params) {
	vm.$u.api.getAboutUs(params).then(res=>{
  		if(res.code==200){
  			vm.content=res.data.value;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 协助保单列表
 * @param {Object} vm
 * @param {Object} params
 */
export function getAssistList(vm,params) {
	vm.$u.api.getAssistList(params).then(res=>{
  		if(res.code==200){
  			if(res.count == 0){
  				vm.isEmpty = true;
  			}else{
  				vm.isEmpty = false;
  				if(res.count<=vm.pageSize){
  					vm.status = 'nomore';
  				}
				// console.log("sssss==="+JSON.stringify(res.data))
  				vm.dataList = vm.dataList.concat(res.data);
  				vm.total=res.count;
  			}
  		}else{
  			vm.isEmpty = true;
  			apiError(vm,res)
  		}
	});
}

/**
 * 获取用户code和name
 * @param {Object} vm
 * @param {Object} params
 */
export function getAssistCode(vm,params) {
	vm.$u.api.getAssistCode(params).then(res=>{
  		vm.setAssInfo(res)
	});
}
/**
 * 查看订单物流
 * @param {Object} vm
 * @param {Object} params
 */
export function orderExpress(vm,params) {
	vm.$u.api.orderExpress(params).then(res=>{
  		if(res.code==200){
			vm.list = res.data.express
			// if(vm.info.Traces == undefined){
			// 	vm.isEmpty = true;
			// }
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 查看拼团订单物流
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingExpress(vm,params) {
	vm.$u.api.sharingExpress(params).then(res=>{
  		if(res.code==200){
			vm.info = res.data
			if(vm.info.Traces == undefined){
				vm.isEmpty = true;
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 查看秒杀订单物流
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedExpress(vm,params) {
	vm.$u.api.timeLimitedExpress(params).then(res=>{
  		if(res.code==200){
			vm.info = res.data
			if(vm.info.Traces == undefined){
				vm.isEmpty = true;
			}
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 用户协议
 * @param {Object} vm
 * @param {Object} params
 */
export function getXieyi(vm,params) {
	vm.$u.api.getXieyi(params).then(res=>{
  		if(res.code==200){
			vm.content = res.data
  		}
	});
}
/**
 * 绑定推荐人
 * @param {Object} vm
 * @param {Object} params
 */
export function addSpread(vm,params) {
	vm.modelShow=true;
	vm.$u.api.addSpread(params).then(res=>{
		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.invitationCode="";
			vm.modelShow = false;
		}else{
			vm.$u.toast(res.msg);
		}
	});
}

/**
 * 拼团公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function paySharingOrderGzh(vm,params) {
	vm.$u.api.paySharingOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=2",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=2",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function payTimeLimitedOrderGzh(vm,params) {
	vm.$u.api.payTimeLimitedOrder(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 jumpPage(vm,"navigateTo","/goods/payResult?type=1",{});
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function orderPayGzh(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为订单列表，1为订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 //类型  0为订单列表，1为订单详情
						 if(params.type == 0){
							vm.orderList=[];
							vm.pageStart = 1;
							vm.selectOrder();
						 }else{
						 	vm.selectOrderDetail();
						 }
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单支付宝支付
 * @param {Object} vm
 * @param {Object} params
 */
export function orderPayZfb(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		if(res.code==200){
			// #ifdef H5
			// location.href  = res.data.payment
			let order_no = res.data.order.order_no
			uni.navigateTo({
				url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
			});
			return;
			// #endif
			// #ifdef APP-PLUS
			if(res.data.is_hui == 1){
				let order_no = res.data.order.order_no
				uni.navigateTo({
					url: '/pages/index/web-view?order_no='+order_no+'&url='+encodeURIComponent(res.data.payment)
				});
				return;
			}else{
				uni.requestPayment({
				    provider: 'alipay',
				    orderInfo: res.data.payment, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				    success: function (res) {
				        jumpPage(vm,"navigateTo","/goods/payResult?type=0",{});
				    },
				    fail: function (err) {
				        console.log('fail:' + JSON.stringify(err));
				    }
				});
			}
			// #endif
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 订单H5支付
 * @param {Object} vm
 * @param {Object} params
 */
export function orderPayh5(vm,params) {
	vm.$u.api.orderPay(params).then(res=>{
		if(res.code==200){
			//location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://testwap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
			location.href  = res.data.payment.mweb_url+"&redirect_url="+encodeURI("https://wap.yunxingzhan.com/h5/user/orderlist?swiperCurrent=0")
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 秒杀订单公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function timeLimitedGoPayGzh(vm,params) {
	vm.$u.api.timeLimitedGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为订单列表，1为订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 //类型  0为订单列表，1为订单详情
						 if(params.type == 0){
										vm.orderList=[];
										vm.pageStart = 1;
										vm.selectOrder();
						 }else{
						 	vm.selectOrderDetail();
						 }
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}

		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 拼团订单公众号支付
 * @param {Object} vm
 * @param {Object} params
 */
export function sharingGoPayGzh(vm,params) {
	vm.$u.api.sharingGoPay(params).then(res=>{
		if(res.code==200){
			if(res.data.type == 'balance'){
				//类型  0为订单列表，1为订单详情
				if(params.type == 0){
					vm.orderList=[];
					vm.pageStart = 1;
					vm.selectOrder();
				}else{
					vm.selectOrderDetail();
				}
			}else{
				WeixinJSBridge.invoke('getBrandWCPayRequest', res.data.payment, function(respay) {
					if (respay.err_msg === "get_brand_wcpay_request:ok") {
						 //类型  0为订单列表，1为订单详情
						 if(params.type == 0){
										vm.orderList=[];
										vm.pageStart = 1;
										vm.selectOrder();
						 }else{
						 	vm.selectOrderDetail();
						 }
					} else if (respay.err_msg === "get_brand_wcpay_request:cancel") {
						uni.showToast({
							title:"取消支付",
							icon:"none",
							duration:2000
						})
					} else if (respay.err_msg === "get_brand_wcpay_request:fail") {
						uni.showToast({
							title:"支付失败",
							icon:"none",
							duration:2000
						})
					}
				}, function(err) {
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 首页公告信息
 * @param {Object} vm
 * @param {Object} params
 */
export function storeInfo(vm,params) {
	vm.$u.api.storeInfo(params).then(res=>{
  		if(res.code==200){
  			vm.noticeList = res.data.notice;
			if(res.data.notice_img){
				vm.noticeImg = res.data.notice_img.file_url
			}
			//测试秒杀用
			if(res.data.active_id){
				vm.active_id = res.data.active_id;
			}
			vm.hdSta(res.data);
			if(vm.noticeImg!=""&&vm.noticeImg!=null){
				vm.show = true;
			}
			// #ifdef MP-WEIXIN
			// if(vm.noticeImg!=""&&vm.noticeImg!=null){
			// 	vm.show = true;
			// }
			// #endif
  		}else{
  			vm.isEmpty = true;
  			apiError(vm,res)
  		}
	});
}

/**
 * 修改交易密码
 * @param {Object} vm
 * @param {Object} params
 */
export function editPayPass(vm,params) {
	vm.$u.api.editPayPass(params).then(res=>{
  		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.editPayPasswordShow=false;
			vm.old_pass='';
			vm.new_pass='';
			vm.confirm_pass='';
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 物流详细信息
 * @param {Object} vm
 * @param {Object} params
 */
export function getExpress(vm,params) {
	vm.$u.api.getExpress(params).then(res=>{
		if(res.State === "0"){
			vm.isEmpty = true
			vm.modalShow = true
		}else{
			vm.isEmpty = false
			vm.expressList=res.Traces;
			vm.modalShow = true
		}
	});
}

/**
 * 从版本更新
 * @param {Object} vm
 * @param {Object} params
 */
export function edition(vm,params) {
	vm.$u.api.edition(params).then(res=>{
		if(res.code==200){
			if(res.data.is_gengxin == 1){
				vm.doUpData(res.data.url);
			}else if(res.data.is_gengxin == 2){
				uni.showModal({
					title: "发现新版本",
					content: "确认下载更新",
					success: (res1) => {
						if (res1.confirm == true) {//当用户确定更新，执行更新
							vm.doUpData(res.data.url);
						}
					}
				})
			}
		}else{
			apiError(vm,res)
		}
	})
}


/**
 * 跳转页面
 * @param {Object} vm 当前页面
 * @param {Object} type navigateTo或to对应uni.navigateTo，redirect或redirectTo对应uni.redirectTo，switchTab或tab对应uni.switchTab，reLaunch对应uni.reLaunch，navigateBack或back对应uni.navigateBack
 * @param {Object} path 跳转地址
 * @param {Object} params 传递的对象形式的参数，如{name: 'lisa', age: 18}
 */
function jumpPage(vm,type,path,params){
	vm.$u.route({
		type:type,
		url:path,
		params:params
	});
}

/**
 * API错误返回
 * @param {Object} vm 当前接口
 * @param {Object} res 返回结果
 */
function apiError(vm,res){

	if(res.code>=410000&&res.code<=410002){
		vm.$refs.loginModel.showModel();
	}else{
		if(res.updateType==2){

		}else{
			if(vm.localModel){
				vm.$refs.uToast.show({title: res.msg})
			}else{
				vm.$u.toast(res.msg);
			}
		}
	}
	return;
}
/**
 * 转帐 Leo   2021年10月12日13:57:02
 * @param {Object} vm
 * @param {Object} params
 */
export function transferReq(vm,params) {
	vm.$u.api.transfer(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			vm.$u.toast(res.msg);
			vm.transferModel=false;
			// vm.$refs.uCode.start();
			vm.selectDistributeLog();
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 根据邀请码查询会员名
 * @param {Object} vm 当前接口
 * @param {Object} res 返回结果
 */
export function spreadCodeName(vm,params){
	vm.$u.api.spreadCodeName(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			// vm.$u.toast(res.msg);
			vm.spread_code_name=res.data;
			// vm.$refs.uCode.start();
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 拼团中奖名单
 * @param {Object} vm
 * @param {Object} params
 */
export function pinFreeUser(vm,params) {
	vm.$u.api.pinFreeUser(params).then(res=>{
		if(res.code==200){
			vm.$set(vm,'freeUserList',res.data.list)
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 代购确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function assistOrderCart(vm,params) {
	vm.$u.api.assistOrderCart(params).then(res=>{
		if(res.code==200 || res.code==300){
			vm.order = res.data;
			vm.goodsList = res.data.goods_list;
			vm.invite_code = res.data.invite_code;
			vm.invite_name = res.data.invite_name;
			vm.hdgoods=res.data.goods_zs;
			vm.h5_show_ali = res.data.paystate.h5_show_ali
			vm.h5_show_wx = res.data.paystate.h5_show_wx
			vm.app_show_ali = res.data.paystate.app_show_ali
			vm.app_show_wx = res.data.paystate.app_show_wx
			vm.mini_show_ali = res.data.paystate.mini_show_ali
			vm.mini_show_wx = res.data.paystate.mini_show_wx
			if(res.data.goods_list.length>0){
				vm.q_id = res.data.goods_list[0].q_id;
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 创建礼品
 * @param {Object} vm
 * @param {Object} params
 */
export function createGift(vm,params) {
	vm.$u.api.createGift(params).then(res=>{
		if(res.code==200){
			let gift_no = res.data.gift_no
			uni.setStorageSync('gift_spread_code', res.data.spread_code);
			jumpPage(vm,"navigateTo",`/goods/giftSuccess?gift_no=${gift_no}`,{});
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 创建礼品订单
 * @param {Object} vm
 * @param {Object} params
 */
export function createGiftOrder(vm,params) {
	vm.$u.api.createGiftOrder(params).then(res=>{
		if(res.code==200){
			let gift_no = res.data.gift_no
			jumpPage(vm,"navigateTo",`/user/orderlist?qid=2`,{});
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 礼品信息
 * @param {Object} vm
 * @param {Object} params
 */
export function giftInfo(vm,params) {
	vm.$u.api.giftInfo(params).then(res=>{
		if(res.code==200){
			vm.info = res.data.info
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 领取礼品
 * @param {Object} vm
 * @param {Object} params
 */
export function receiveGift(vm,params) {
	vm.$u.api.receiveGift(params).then(res=>{
		if(res.code==200){
			let gift_no = res.data.gift_no
			jumpPage(vm,"navigateTo",`/goods/giftOrder`,{});
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 发送记录
 * @param {Object} vm
 * @param {Object} params
 */
export function sendList(vm,params) {
	vm.$u.api.sendList(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
			vm.spread_code = res.data.spread_code
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 领取记录
 * @param {Object} vm
 * @param {Object} params
 */
export function receiveList(vm,params) {
	vm.$u.api.receiveList(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
			vm.spread_code = res.data.spread_code
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 礼品领取记录
 * @param {Object} vm
 * @param {Object} params
 */
export function giftReceiveList(vm,params) {
	vm.$u.api.giftReceiveList(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 获取订单详情
 * @param {Object} vm
 * @param {Object} params
 */
export function newOrder(vm,params) {
	vm.$u.api.newOrder(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 收银台支付
 * @param {Object} vm
 * @param {Object} params
 */
export function newPay(vm,params) {
	vm.$u.api.newPay(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

export function exchangeList(vm,params) {
	vm.$u.api.exchangeList(params).then(res=>{
  		if(res.code==200){
			vm.roomList = res.data;
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 兑换详情页
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeDetail(vm,params) {
	vm.$u.api.exchangeDetail(params).then(res=>{
  		if(res.code==200){
			vm.goodsInfo  = res.data.goods;
			if(vm.goodsInfo.spec_type == 2){
				vm.skuList = res.data.goods.goods_multi_spec.spec_attr;
			}
			vm.exchangeInfo = res.data;
			vm.goods_id = vm.exchangeInfo.goods_id;
			vm.setFrom(res.data.goods.content); //处理商品详情
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 预售订单
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeOrderList(vm,params) {
	vm.$u.api.exchangeOrderList(params).then(res=>{
		if(res.code==200){
			vm.orderList = res.data.list
		}else{
			vm.$u.toast(res.msg);
		}
	})
}

/**
 * 创建预售支付订单
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeCreateOrder(vm,params) {
	vm.$u.api.exchangeCreateOrder(params).then(res=>{
		if(res.code==200){
			vm.modalShow = true;
			vm.order_id = res.data.order_id;
			vm.pay_price = res.data.pay_price;
			//var qid = res.data.q_id - 1;
			//jumpPage(vm,"navigateTo",`/user/orderlist?qid=`+qid,{});
		}else{
			vm.$u.toast(res.msg);
		}
	})
}


/**
 * 预售购买
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeBuy(vm,params) {
	vm.$u.api.exchangeBuy(params).then(res=>{
  		if(res.code==200){
			vm.buy_status = 1;
			vm.code = 200;
			vm.goToOrder()
  		}else{
			vm.code = res.code;
			apiError(vm,res);
		}
	});
}


/**
 * 预售确认订单
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeOrder(vm,params) {
	vm.$u.api.exchangeOrder(params).then(res=>{
		if(res.code==200){
			vm.order = res.data;
			if(res.data.fail.code == 0){
				vm.$u.toast(res.data.fail.msg);
			}
			//判断选择收货地址
			let address = uni.getStorageSync('address')|| '';
			if(address != ''){
				vm.order.address = address;
			}
			uni.setStorageSync('address', "");
		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 兑换小程序支付
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangePay(vm,params) {
	vm.$u.api.exchangePay(params).then(res=>{
		uni.hideLoading();
		if(res.code==200){
			jumpPage(vm,"navigateTo","/goods/payResult?type=11",{});
		}else{
			apiError(vm,res)
		}
	})
}

/**
 * 查看兑换订单物流
 * @param {Object} vm
 * @param {Object} params
 */
export function exchangeExpress(vm,params) {
	vm.$u.api.exchangeExpress(params).then(res=>{
  		if(res.code==200){
			vm.list = res.data.express
			// if(vm.info.Traces == undefined){
			// 	vm.isEmpty = true;
			// }
  		}else{
			apiError(vm,res)
		}
	});
}

/**
 * 物流详细信息
 * @param {Object} vm
 * @param {Object} params
 */
export function getExchangeExpress(vm,params) {
	vm.$u.api.getExchangeExpress(params).then(res=>{
		if(res.State === "0"){
			vm.isEmpty = true
			vm.modalShow = true
		}else{
			vm.isEmpty = false
			vm.expressList=res.Traces;
			vm.modalShow = true
		}
	});
}

/**
 * 查询会员信息
 * @param {Object} vm
 * @param {Object} params
 */
export function ywfx(vm,params) {
	vm.$u.api.ywfx(params).then(res=>{
		if(res.code==200){
			vm.accountList[0] = res.data.shequn;
			vm.accountList[1] = res.data.small;
			vm.accountList[2] = res.data.vip;
			vm.accountList[3] = res.data.zt;
			vm.accountList[4] = res.data.yx;
			vm.tabsCurrent = 2;
			vm.isLogin = true;
		}else{
			vm.noticeList=["请登录"];
			apiError(vm,res)
		}
	});
}
